package com.Interface.service;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.Interface.dao.ActivityUserInfoMapper;
import com.Interface.dao.TopicInfoMapper;
import com.Interface.entity.ActivityUserInfo;

@Service
public class ActivityInfoService {
	
	@Autowired
	ActivityUserInfoMapper activityUserInfoDao;
	
	@Autowired
	TopicInfoMapper topicDao;
	
	public int userIsJoin(Map<String, Object> param){
		   return activityUserInfoDao.userIsJoin(param);
	}
	public String userJoin(Map<String, Object> param){
		String rltdesc ="";
		int rlt = userIsJoin(param);
		if(rlt>0){
			rltdesc = "您已经参加了该活动";
		}else{
			ActivityUserInfo info = new ActivityUserInfo();
			info.setCreateTime(new Date());			
			info.setTopicId( Integer.parseInt(param.get("topic_id").toString()));
			info.setUserId(Integer.parseInt(param.get("user_id").toString()));
			activityUserInfoDao.insertSelective(info);
			topicDao.updateJoinCnt(Integer.parseInt(param.get("topic_id").toString()));
		}
		return rltdesc;
	}
}
